'''
Created on Apr 28, 2011

@author: user
'''
from sets import Set

primes_under_100 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
def isprime(n):
    if n <= 100:
        return n in primes_under_100
    if n % 2 == 0 or n % 3 == 0:
        return False

    for f in range(5, int(n ** .5), 6):
        if n % f == 0 or n % (f + 2) == 0:
            return False
    return True 


def nextPrime(x):
    p = x + 1
    while isprime(p) == False:
        p = p + 1
    return p

def primeDivisor(x):
    primeList = []
    
    iPrime = 2
    
    while x > 1:
        print x
        if x%iPrime != 0:
            iPrime = nextPrime(iPrime)
        else:
            x = x / iPrime
            primeList.append(iPrime)
            
    primeSet = Set(primeList)
    print primeSet
    
    sum = 0
    for i in primeSet:
        sum = sum + i
    print sum        
        
        
    

if __name__ == '__main__':
    primeDivisor(514229+1)